package easy;

import java.util.HashMap;
import java.util.HashSet;

/*
1748. 唯一元素的和
解题思路：使用哈希表
 */
public class LeeCode1748 {

  public int sumOfUnique(int[] nums) {

    HashMap<Integer, Integer> map = new HashMap<>();
    for (int num : nums) {
      map.put(num,map.getOrDefault(num,0)+1);
    }
    int res = 0;
    for (Integer integer : map.keySet()) {
      if (map.get(integer) == 1){
        res = res + integer;
      }
    }
    return res;
  }

  public static void main(String[] args) {
    System.out.println(new LeeCode1748().sumOfUnique(new int[]{1,2,3,2}));
  }
}
